﻿using Mes.Domain.BoundedContext.Entities.WorkOrders;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.WorkOrders
{
    public class JobHourHistoryEntityConfig : IEntityTypeConfiguration<JobHourHistory>
    {
        public void Configure(EntityTypeBuilder<JobHourHistory> builder)
        {
            builder.ToTable("job_hour_history");
            builder.HasKey(b => new { b.Wo_Id, b.Oper_Id, b.Ent_Id, b.Job_Start_Utc,b.Hour_Start_Utc });
            builder.Property(b => b.Ent_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Wo_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Oper_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Job_Start_Utc).IsRequired();
            builder.Property(b => b.Hour_Start_Utc).IsRequired();
            builder.Property(b => b.Hour_Start_Local).IsRequired();
            builder.Property(b => b.Hour_End_Utc).IsRequired();
            builder.Property(b => b.Hour_End_Local).IsRequired();
            builder.Property(b => b.Item_Id).IsRequired();
            builder.Property(b => b.Std_Prod_Rate).IsRequired();
            builder.Property(b => b.Batch_Size).IsRequired();
            builder.Property(b => b.Qty_Good).IsRequired();
            builder.Property(b => b.Qty_Reject).IsRequired();
            builder.Property(b => b.Runtime).IsRequired();
            builder.Property(b => b.Downtime).IsRequired();
            builder.Property(b => b.Idletime).IsRequired();
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
